<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class EsMobil {
    const RE_MOBILE='/(nokia|iphone|android|motorola|^mot\-|softbank|foma|docomo|kddi|up\.browser|up\.link|htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam\-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|symbian|smartphone|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte\-|longcos|pantech|gionee|^sie\-|portalmmm|jig\s browser|hiptop|^ucweb|^benq|haier|^lct|opera\s*mobi|opera\*mini|320x320|240x320|176x220)/i';
    private $_esMobil= false;

    public  function  __construct() {
        $this->_esMobil= $this->esMobil();
    }

    public function getEsMobil() {
        return $this->_esMobil;
    }

    public function getDispositiu() {
        if ($this->_esMobil) return 'Mòbil';
        else return 'PC';
    }

    private function esMobil() {
        return isset($_SERVER['HTTP_X_WAP_PROFILE']) || isset($_SERVER['HTTP_PROFILE']) ||
            preg_match(self::RE_MOBILE, $_SERVER['HTTP_USER_AGENT']);
    }
}

